package com.jcj.jcjregistry.config;

import com.jcj.jcjregistry.cluster.Cluster;
import com.jcj.jcjregistry.health.HealthChecker;
import com.jcj.jcjregistry.health.JcjHealthChecker;
import com.jcj.jcjregistry.service.JcjRegistryService;
import com.jcj.jcjregistry.service.RegistryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RegistryConfig {
    @Bean
    public RegistryService registryService() {
        return new JcjRegistryService();
    }

    @Bean(initMethod = "start", destroyMethod = "stop")
    public HealthChecker healthChecker(RegistryService registryService) {
        return new JcjHealthChecker(registryService);
    }

    @Bean(initMethod = "init")
    public Cluster cluster(@Autowired JcjRegistryProperties jcjRegistryProperties) {
        return new Cluster(jcjRegistryProperties);
    }
}
